//
//  WebViewController.m
//  BenChiWeb
//
//  Created by xue on 2018/3/28.
//  Copyright © 2018年 Soowin. All rights reserved.
//

#import "WebViewController.h"
#define SCREEN_WIDTH    [UIScreen mainScreen].bounds.size.width
#define SCREEN_HEIGHT   [UIScreen mainScreen].bounds.size.height
#define kStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height
#define SafeAreaBottomHeight (SCREEN_HEIGHT == 812.0 ? 34 : 0)

@interface WebViewController ()<UIWebViewDelegate>
@property (nonatomic,strong) UIWebView * webView;
@end

@implementation WebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,kStatusBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-kStatusBarHeight-SafeAreaBottomHeight)];
    _webView.delegate =self;
    _webView.scalesPageToFit=YES;
    [self.view addSubview:self.webView];
    [self.webView sizeToFit];
    
    
    [self loadString:@"http://benz-zw1.wx.fractalist.com.cn/CarService/Index"];
}
- (void)loadString:(NSString *)str  {
    
    NSURL *url = [NSURL URLWithString:str];
    // 2. 把URL告诉给服务器,请求,从m.baidu.com请求数据
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    // 3. 发送请求给服务器
    [self.webView loadRequest:request];
    [self.view addSubview:self.webView];
}

//开始加载网页
- (void)webViewDidStartLoad:(UIWebView *)webView{
    
    
}
//网页加载完成
- (void)webViewDidFinishLoad:(UIWebView *)webView{
    
}
//网页加载错误
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    NSLog(@"ssss=%@",error);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
